package com.mql.learnSpringCloud.controller;


import com.example.cloudapicommons.entity.CommonResult;
import com.example.cloudapicommons.entity.PaymentEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {
    @Value("${service-url.nacos-user-service}")
    private String PAYMENT_URL;
@Autowired
private RestTemplate restTemplate;

@PostMapping("/consumer/payment/save")
public CommonResult<PaymentEntity> save(@RequestBody PaymentEntity paymentEntity){

    return restTemplate.postForObject(PAYMENT_URL+"/maQingLin/save",paymentEntity,CommonResult.class);
}

@GetMapping("/consumer/payment/get/{id}")
public CommonResult<PaymentEntity> getPayment(@PathVariable("id")Integer id){
    return restTemplate.getForObject(PAYMENT_URL+"/maQingLin/get/"+id,CommonResult.class);
}
}
